﻿namespace DynaBoard
{

    using System.Linq;
    using System;
    using System.Collections.Generic;

public partial class Board
{
    public static string NameFromId(int boardId)
    {
        using (var db = DynaBoardDataContext.Create)
        {
            return (from board in db.Board
                    where board.Id == boardId
                    select board.Name).Single();
        }
    }

    public static KeyValuePair<int, string>[] ListAll()
    {
        using (var db = DynaBoardDataContext.Create)
        {
            return (from board in db.Board
                    select new KeyValuePair<int, string>
                    (
                        board.Id,
                        board.Name
                    )).ToArray();
        }
    }

    public static Board FromPostId(int postId)
    {
        using (var db = DynaBoardDataContext.Create)
        {
            return (from post in db.Post
                    from board in db.Board
                    where post.Id == postId
                    where board.Id == post.BoardId
                    select board).Single();
        }
    }
}

}